export default class EventRouter {
  #api = {}
  routers
  constructor() {
    this.routers = new Array()
  }
  //添加api
  addApi(key, api) {
    this.#api[key] = api
  }
  //添加多个路由
  addRouters(routers) {
    this.routers = this.routers.concat(routers)
  }
  //触发执行名称的路由回调
  router(data) {
    console.log(data)
    for (let i = 0; i < this.routers.length; i++) {
      const r = this.routers[i]
      console.log()
      if (data.name == r.name) {
        console.log('aaa', '进入了')
        r.callback(this.#api, data.data)
      }
    }
  }
}
